package com.hst.capacity.infra.persistence.jpa.setting.price;

import com.hst.capacity.domain.model.entity.setting.price.ExpressStpPriceEntity;
import com.hst.capacity.domain.model.entity.setting.price.SpecialCarPriceEntity;
import com.hst.capacity.domain.model.response.setting.price.IntercitySearchVO;
import com.hst.capacity.domain.model.response.setting.price.SpecialCarPriceVO;
import com.hst.capacity.domain.model.response.setting.price.SpecialCarSearchVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SpecialCarPriceRepository extends JpaRepository<SpecialCarPriceEntity, String> {

    @Query("select new com.hst.capacity.domain.model.response.setting.price.SpecialCarSearchVO(p) from SpecialCarPriceEntity p where p.idFranchisee=:idFranchisee")
    Page<SpecialCarSearchVO> findByIdFranchisee(String idFranchisee, PageRequest pageRequest);

    SpecialCarPriceEntity findByIdFranchiseeAndRegionCodeAndIdVehicleTypeAndIdServiceType(String idf,String reg,String vet,String ist);

    @Query("select new com.hst.capacity.domain.model.response.setting.price.SpecialCarPriceVO(p, r) from SpecialCarPriceEntity p left join RegionEntity r on p.regionCode = r.code where p.idServicePriceType=:idPrice")
    SpecialCarPriceVO findByIdPrice(String idPrice);

//    /**
//     * 通过地区查找站点价格
//     * @param regionCode
//     * @param carpoolType（0：拼车 1：包车）
//     * @return
//     */
//    List<SpecialCarPriceEntity> findByRegionCodeAndCarpoolType(String regionCode, int carpoolType);

}